package calculator.model;/*
 * @author     ：zhangbo
 * @date       ：Created in 2021/5/22 11:35
 * @description：负运算
 * @modified By：zhangbo
 * @version:     $
 */

public class PorN implements MathComputer {
    @Override
    public void handle(Computer data) {
        String s = "";
        double r = data.computerDataItem();
        r = -r;
        Double d = new Double(r);
        long n = d.longValue();
        if (Math.abs(r - n) > 0) {
            s = "" + r;
        } else {
            s = "" + n;
        }
        data.dataItem.removeAllElements();
        for (int i = 0; i < s.length(); i++) {
            data.dataItem.push(s.charAt(i));
        }
    }
}
